package com.controller;


import com.model.Customer;
import com.page.GenericPage;
import com.po.AdvertisementPO;
import com.po.CustomerAccountPO;
import com.po.CustomerPO;
import com.po.CustomerQueryPO;
import com.result.Result;
import com.service.CustomerAccountService;
import com.service.CustomerService;
import com.vo.AdvertisementVO;
import com.vo.CustomerAccountVO;
import com.vo.CustomerVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: chihaojie
 * @Date: 2019/5/29 14:08
 * @Version 1.0
 * @Note
 */


@Api(value = "customerApi")
@CrossOrigin
@RestController
@RequestMapping("/customer")
public class CustomerController {


    @Autowired
    private CustomerService customerService;

    /**
     * 判断是否已经注册
     */


    /**
     * 注册
     */


    @ApiOperation(value = "保存", httpMethod = "POST", notes = "保存")
    @RequestMapping(value = "/save", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<CustomerVO> save(@RequestBody CustomerPO customerPO) {
        return new Result<CustomerVO>().ok(customerService.save(customerPO));
    }

    @ApiOperation(value = "查询", httpMethod = "POST", notes = "查询")
    @RequestMapping(value = "/queryAll", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<GenericPage<CustomerVO>> queryAll(@RequestBody CustomerQueryPO customerQueryPO) {
        return customerService.queryAll(customerQueryPO);
    }

    @ApiOperation(value = "修改", httpMethod = "POST", notes = "修改")
    @RequestMapping(value = "/modifyById", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
    public Result<Boolean> modifyById(@RequestBody Customer customer) {
        return customerService.modifyById(customer);
    }

}
